Skip to content

feat: adding start() method to common client sdk package#1244

Merged
joker23 merged 9 commits into
mainfrom
skz/sdk-1759/client-start
Apr 16, 2026
Merged

feat: adding start() method to common client sdk package#1244
joker23 merged 9 commits into
mainfrom
skz/sdk-1759/client-start

Conversation

@joker23

@joker23 joker23 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

This PR will consolidate the start() method into the shared client sdk package.

To do this we also:

  • introduce an internal option called requiresStart which should be true for new SDKs (and only RN has it default false)
  • requiresStart is, effectively, a feature flag for whether the SDK is using the new create + start initialization pattern
  • consolidated the unit tests for the start method into client common
  • moved start method out of browser and electron sdks

Note

Medium Risk
Touches core initialization/identify behavior across multiple SDKs and changes when bootstrap parsing and goal tracking occur, which could affect startup sequencing and existing integrations if edge cases regress.

Overview
Moves the start() implementation (including bootstrap flag preloading and init promise caching/timeout behavior) from the Browser and Electron SDKs into the shared packages/shared/sdk-client LDClientImpl.

Introduces LDStartOptions in the shared API and adds internal options requiresStart and initialContext so platform SDKs can enforce the new create+start() initialization pattern; identifyResult() now blocks pre-start() calls when requiresStart is enabled and updates the logged error message.

Updates Browser/Electron wrappers and tests accordingly (Browser/Electron remove their custom start() logic, Browser ensures goal tracking only starts after start()), and adds a consolidated LDClientImpl.start() test suite in the shared package.

Reviewed by Cursor Bugbot for commit 5c9e61f. Bugbot is set up for automated code reviews on this repo. Configure here.


Open with Devin

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25623 bytes
Compressed size limit: 29000
Uncompressed size: 125843 bytes

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179425 bytes
Compressed size limit: 200000
Uncompressed size: 830289 bytes

@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 1a440b9 to d249ad8 Compare April 3, 2026 23:36
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31731 bytes
Compressed size limit: 34000
Uncompressed size: 113100 bytes

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 37607 bytes
Compressed size limit: 38000
Uncompressed size: 207149 bytes

@joker23

joker23 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d249ad8. Configure here.

@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from d249ad8 to 8f1e564 Compare April 6, 2026 18:54
@joker23 joker23 marked this pull request as ready for review April 6, 2026 19:25
@joker23 joker23 requested a review from a team as a code owner April 6, 2026 19:25
Comment thread packages/shared/sdk-client/__tests__/LDClientImpl.start.test.ts
* When true, the SDK requires `start()` to be called before `identify()`.
* Set this value to `true` to use the new initialization pattern.
*/
requiresStart?: boolean;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this to compat react native... this was the only way I found that would leave RN alone

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 8f1e564 to 111c7e2 Compare April 7, 2026 15:26
cursor[bot]

This comment was marked as resolved.

Comment thread packages/sdk/browser/__tests__/BrowserClient.test.ts
Comment thread packages/shared/sdk-client/src/LDClientImpl.ts Outdated
@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 66673ed to 8b2405c Compare April 10, 2026 17:48
cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch 2 times, most recently from ad291be to 0af525e Compare April 10, 2026 20:38
@joker23 joker23 requested a review from kinyoklion April 10, 2026 20:42
const bootstrapModule = await import('@launchdarkly/js-client-sdk-common');
const readFlagsFromBootstrapSpy = jest.spyOn(bootstrapModule, 'readFlagsFromBootstrap');

it('parses bootstrap data when start is called with bootstrap', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me assume it parses it more than once? Which actually I think was already true? Once synchronously and again during the identify process? But what behavior change is this test change for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should have been moved to the shared instance. I think the reason the test changed in this way is that there is no longer a way to test that behavior on this level.

}

let effectiveOptions = identifyOptions;
if (this._requiresStart && identifyOptions?.sheddable === undefined) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that I like coupling of the default shedding behavior to the _requiresStart behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay - yea I got a little too ambitious with trying to change the common default option to be sheddable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so for this one, I decided to revert to the old defaults (sheddable is false) and have the browser and electron override that (which is what they did before)

* Sets the initial context for the client. This must be called before `start()`.
* @param context The initial context.
*/
setInitialContext(context: LDContext): void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be protected. React directly exposes the inheritance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may present somewhat of a problem to the approach. So maybe we can figure out another approach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this, I decided to get rid of this function altogether and introduced a new internal option that is initialContext

cursor[bot]

This comment was marked as resolved.

@joker23 joker23 requested a review from kinyoklion April 13, 2026 20:26
@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch 2 times, most recently from 51c47b1 to 1284889 Compare April 14, 2026 16:37
@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 1284889 to 8289496 Compare April 14, 2026 16:54
@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 8289496 to 5cf93ab Compare April 15, 2026 17:09
@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 5cf93ab to e3c5cc7 Compare April 15, 2026 20:41
cursor[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-1759/client-start branch from 39e0210 to 289e6fa Compare April 16, 2026 17:37
@joker23 joker23 merged commit 7f5f468 into main Apr 16, 2026
47 checks passed
@joker23 joker23 deleted the skz/sdk-1759/client-start branch April 16, 2026 21:59
@github-actions github-actions Bot mentioned this pull request Apr 16, 2026
joker23 pushed a commit that referenced this pull request Apr 17, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>browser: 0.1.15</summary>

##
[0.1.15](browser-v0.1.14...browser-v0.1.15)
(2026-04-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from 4.5.0 to 4.6.0
</details>

<details><summary>browser-telemetry: 1.0.31</summary>

##
[1.0.31](browser-telemetry-v1.0.30...browser-telemetry-v1.0.31)
(2026-04-17)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-client-sdk bumped from 4.5.0 to 4.6.0
</details>

<details><summary>cloudflare-server-sdk: 2.7.19</summary>

##
[2.7.19](cloudflare-server-sdk-v2.7.18...cloudflare-server-sdk-v2.7.19)
(2026-04-17)


### Bug Fixes

* remove `rollup-plugin-dts` dependency
([#1288](#1288))
([ea64b82](ea64b82))
</details>

<details><summary>jest: 1.0.10</summary>

##
[1.0.10](jest-v1.0.9...jest-v1.0.10)
(2026-04-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/react-native-client-sdk bumped from ~10.15.2 to ~10.16.0
</details>

<details><summary>js-client-sdk: 4.6.0</summary>

##
[4.6.0](js-client-sdk-v4.5.0...js-client-sdk-v4.6.0)
(2026-04-17)


### Features

* adding start() method to common client sdk package
([#1244](#1244))
([7f5f468](7f5f468))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.24.0 to 1.25.0
</details>

<details><summary>js-client-sdk-common: 1.25.0</summary>

##
[1.25.0](js-client-sdk-common-v1.24.0...js-client-sdk-common-v1.25.0)
(2026-04-17)


### Features

* Add experimental FDv2 support for React Native.
([#1243](#1243))
([7ed2c08](7ed2c08))
* adding start() method to common client sdk package
([#1244](#1244))
([7f5f468](7f5f468))


### Bug Fixes

* FDv2 -- cache initializer returns transfer-none on cache miss
([#1275](#1275))
([7bf3c31](7bf3c31))
</details>

<details><summary>react-native-client-sdk: 10.16.0</summary>

##
[10.16.0](react-native-client-sdk-v10.15.2...react-native-client-sdk-v10.16.0)
(2026-04-17)


### Features

* Add experimental FDv2 support for React Native.
([#1243](#1243))
([7ed2c08](7ed2c08))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.24.0 to 1.25.0
</details>

<details><summary>react-sdk: 0.2.1</summary>

##
[0.2.1](react-sdk-v0.2.0...react-sdk-v0.2.1)
(2026-04-17)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from ^4.5.0 to ^4.6.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Mostly mechanical version/changelog updates, but it publishes new SDK
versions (including new/experimental client capabilities) which could
affect downstream consumers if the release contents are incorrect.
> 
> **Overview**
> Updates release metadata for a multi-package publish, bumping versions
across the Browser, React Native, React, Cloudflare, combined-browser,
browser-telemetry, and jest packages and updating their changelogs and
example app dependencies accordingly.
> 
> Also updates embedded `x-release-please-version` strings (for
SDK/wrapper reporting) to match the new package versions.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d56c92d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants